package SwordOffer;

import util.PrintUtils;

public class Sword_Offer_17 {

    /*public int[] printNumbers(int n) {
        int length = (int)Math.pow(10, n) - 1;
        int[] array = new int[length];
        for (int i = 1; i <= length; i++) {
            array[i - 1] = i;
        }
        return array;
    }
*/
    public int[] printNumbers(int n) {
        int length = (int)Math.pow(10, n) - 1;
        int[] array = new int[length];
        array[0] = 1;
        array[1] = 2;
        array[2] = 3;
        array[3] = 4;
        array[4] = 5;
        array[5] = 6;
        array[6] = 7;
        array[7] = 8;
        array[8] = 9;
        int base = 0, begin = 0, end = begin + base + 8;
        for (int i = 2; i <= length; i++) {
            base *= 10;
            begin = end + 1;
            end = begin + base + 8;
        }
        return array;
    }

    public static void main(String[] args) {
        Sword_Offer_17 model = new Sword_Offer_17();
        PrintUtils.arrayInt(model.printNumbers(1));
        PrintUtils.arrayInt(model.printNumbers(2));
    }
}
